package com.ldu.exam.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Builder
@Table(name="t_account")
public class AccountModel 
{
	@Id
	@Column(length=32)
	@GeneratedValue(strategy = GenerationType.IDENTITY,generator = "jpa-uuid")
	@GenericGenerator(name = "jpa-uuid",strategy = "uuid.hex")
	private String id ;

	/**
	 * 名称
	 */
	@Column(length=111,nullable=false,unique=true)
	private String name ;
	
	@Column
	private String password ;
	
	/**
	 * 停用 ( true : 停用 ; false or null : 启用 ; )
	 */
	private Boolean suspended ;
	
	private String nickname ;
	
	private String  address ;
	private Integer gender ;
	private Integer age ;
	
	private String summary ;
	
	/**
	 * 状态
	 */
	private String state;
	
	private String email;
	
	private String birthDate;
	

	private String pic;
	
	private String phone;

	private String isExamed;
	
	private String managerClassId;
	
	@ManyToMany(mappedBy="accounts")
	private Set<RoleModel> roles ;
	
	/**
	 * 创建时间
	 */
	@CreationTimestamp
	private Timestamp creationDate ;
	
	/**
	 * 修改时间
	 */
	@UpdateTimestamp
	private Timestamp updateDate ;

	@OneToMany(mappedBy="account")
	@JsonIgnoreProperties(value = {"created","account","studentAccounts"})
	private Set<ClaModel> cla = new HashSet<>();
	
	@ManyToOne
	@JoinColumn(name="class_Id")
	@JsonIgnoreProperties(value = {"created","account","studentAccounts"})
	private ClaModel studentCla ;
}
